package com.xm.adv.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;

import com.xm.adv.activity.MainActivity;

import xinya.com.baselibrary.constant.Constant;
import xinya.com.baselibrary.utils.ACacheX;
import xinya.com.baselibrary.utils.LogUtil;

public class MyReceiver extends BroadcastReceiver {
    public MyReceiver() {
    }

    @Override
    public void onReceive(Context context, Intent intent) {
        if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")) {
            LogUtil.LogShitou("MyReceiver--onReceive", "开机了");
            String openCloseEnable = ACacheX.getAsString(context, Constant.AcacheKey.setInfo, Constant.AcacheValue.openCloseEnable);
            if (TextUtils.isEmpty(openCloseEnable) || TextUtils.equals(openCloseEnable, "true")) {
                Intent i = new Intent(context, MainActivity.class);
                i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                context.startActivity(i);
            }
        }
    }
}